home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / bin / zmore < prev    next >
Text File  |  1995-07-17  |  1KB  |  52 lines

  1. #!/bin/sh
  2.  
  3. PATH="/usr/skunk/bin:$PATH"; export PATH
  4. if test "`echo -n a`" = "-n a"; then
  5.   # looks like a SysV system:
  6.   n1=''; n2='\c'
  7. else
  8.   n1='-n'; n2=''
  9. fi
  10. oldtty=`stty -g 2>/dev/null`
  11. if stty -cbreak 2>/dev/null; then
  12.   cb='cbreak'; ncb='-cbreak'
  13. else
  14.   # 'stty min 1' resets eof to ^a on both SunOS and SysV!
  15.   cb='min 1 -icanon'; ncb='icanon eof ^d'
  16. fi
  17. if test $? -eq 0 -a -n "$oldtty"; then
  18.    trap 'stty $oldtty 2>/dev/null; exit' 0 2 3 5 10 13 15
  19. else
  20.    trap 'stty $ncb echo 2>/dev/null; exit' 0 2 3 5 10 13 15
  21. fi
  22.  
  23. if test $# = 0; then
  24.     if test -t 0; then
  25.     echo usage: zmore files...
  26.     else
  27.     gzip -cdfq | eval ${PAGER-more}
  28.     fi
  29. else
  30.     FIRST=1
  31.     for FILE
  32.     do
  33.     if test $FIRST -eq 0; then
  34.         echo $n1 "--More--(Next file: $FILE)$n2"
  35.         stty $cb -echo 2>/dev/null
  36.         ANS=`dd bs=1 count=1 2>/dev/null` 
  37.         stty $ncb echo 2>/dev/null
  38.         echo " "
  39.         if test "$ANS" = 'e' -o "$ANS" = 'q'; then
  40.             exit
  41.         fi
  42.     fi
  43.     if test "$ANS" != 's'; then
  44.         echo "------> $FILE <------"
  45.         gzip -cdfq "$FILE" | eval ${PAGER-more}
  46.     fi
  47.     if test -t; then
  48.         FIRST=0
  49.     fi
  50.     done
  51. fi
  52.